home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d18 / qwik30.arc / QSTORES.INC < prev    next >
Text File  |  1991-01-09  |  10KB  |  144 lines

  1. { Qstores.inc - transfers blocks between screen and memory. ver 3.0, 08-31-87 }
  2. { These procedures do fast screen transfers of a Rows-by-Cols block to memory
  3.   and vice-versa.  It also automatically configures to your machine since
  4.   Qinit is required.  The upper left column is 1,1.  Cols can range from
  5.   1 to screen limits.                                                         }
  6.  
  7. { QstoreToMem - saves screen display for later use          ver 2.0, 11-24-86 }
  8. procedure QstoreToMem (Row, Col, Rows, Cols: byte; VAR Dest);
  9. begin
  10. Inline(                  {Assembly by Inline 08/17/87 17:53}
  11.   $8B/$5E/<ROWS/         {       mov   bx,[bp+<Rows]    ;Move number of rows}
  12.   $8B/$4E/<COLS/         {       mov   cx,[bp+<Cols]    ;Move number of cols}
  13.                          {                              ;}
  14.   $85/$DB/               {       test  bx,bx            ;If Rows<=0 ...}
  15.   $7E/$63/               {       jle   Exit             ;   nothing to do}
  16.   $85/$C9/               {       test  cx,cx            ;If Cols<=0 ...}
  17.   $7E/$5F/               {       jle   Exit             ;   nothing to do}
  18.                          {                              ;}
  19.   $31/$D2/               {       xor   dx,dx            ;Set DX=0}
  20.   $8E/$C2/               {       mov   es,dx            ;Set ES=0}
  21.   $26/                   {       es:                    ;Segment override}
  22.   $8A/$16/$4A/$04/       {       mov   dl,[$044A]       ;Get CRT columns}
  23.   $8B/$46/<ROW/          {       mov   ax,[bp+<Row]     ;Move row in AX}
  24.   $48/                   {       dec   ax               ;Convert to 0-?? range}
  25.   $F6/$E2/               {       mul   dl               ;(CRT columns)*(Row-1)}
  26.   $89/$C6/               {       mov   si,ax            ;Partial offset in SI}
  27.   $03/$76/<COL/          {       add   si,[bp+<Col]     ;Add Col}
  28.   $4E/                   {       dec   si               ;Convert to 0-?? range}
  29.   $D1/$E6/               {       shl   si,1             ;Source offset calc'd}
  30.   $29/$CA/               {       sub   dx,cx            ;DX=(CRT columns)-Cols}
  31.   $D1/$E2/               {       shl   dx,1             ;Mult by 2}
  32.   $52/                   {       push  dx               ;Save # to next row}
  33.   $51/                   {       push  cx               ;Save Cols}
  34.   $1E/                   {       push  ds               ;Save Turbo's DS}
  35.   $FC/                   {       cld                    ;Set DF to increment}
  36.   $C4/$7E/<DEST/         {       les   di,[bp+<Dest]    ;ES:DI points to Dest}
  37.   $3A/$2E/>QWAIT/        {       cmp   ch,[>Qwait]      ;Check need for wait}
  38.   $8E/$1E/>QSEG/         {       mov   ds,[>Qseg]       ;DS:SI source pointer}
  39.   $75/$0C/               {       jne   Color            ;  use Color routine}
  40.                          {                              ;}
  41.                          {; -- Mono routine; Attr, Char and No Wait--}
  42.   $F2/$A5/               {Mono:  rep   movsw            ;To dest & inc DI 2}
  43.   $4B/                   {       dec   bx               ;Decrement rows left}
  44.   $74/$29/               {       jz    Done             ;If Rows=0, done}
  45.   $8B/$4E/$FA/           {       mov   cx,[bp-$06]      ;Restore Cols}
  46.   $01/$D6/               {       add   si,dx            ;Source for next row}
  47.   $EB/$F4/               {       jmp   SHORT Mono       ;Next row}
  48.                          {                              ;}
  49.                          {; -- Color routine; Attr, Char and Wait --}
  50.   $BA/$DA/$03/           {Color: mov   dx,$03DA         ;CGA port}
  51.   $FA/                   {Col1A: cli                    ;Disable interrupts}
  52.   $EC/                   {E4in:  in    al,dx            ;Check CGA status}
  53.   $A8/$08/               {       test  al,$08           ;If #3 bit set ...}
  54.   $75/$09/               {       jnz   ColrB            ;  skip wait}
  55.   $D0/$D8/               {       rcr   al,1             ;If #0 bit set ...}
  56.   $72/$F7/               {       jc    E4in             ;  try again for $E4}
  57.   $EC/                   {E5in:  in    al,dx            ;Check CGA status}
  58.   $D0/$D8/               {       rcr   al,1             ;If #0 bit clear ...}
  59.   $73/$FB/               {       jnc   E5in             ;  try again for $E5}
  60.   $AD/                   {ColrB: lodsw                  ;Load char & attr}
  61.   $FB/                   {       sti                    ;Enable interrupts}
  62.   $AB/                   {       stosw                  ;Put in dest & inc DI}
  63.   $E2/$EC/               {       loop  Col1A            ;Loop till CX=0}
  64.   $4B/                   {       dec   bx               ;Decrement rows left}
  65.   $74/$08/               {       jz    Done             ;If Rows=0, done}
  66.   $8B/$4E/$FA/           {       mov   cx,[bp-$06]      ;Restore Cols}
  67.   $03/$76/$FC/           {       add   si,[bp-$04]      ;Source for next row}
  68.   $EB/$E1/               {       jmp   SHORT Col1A      ;Next row}
  69.                          {                              ;}
  70.   $1F/                   {Done:  pop   ds               ;Restore Turbo's DS}
  71.   $81/$C4/$04/$00        {       add   sp,$0004         ;Restore stack ptr}
  72.  );                      {Exit:}
  73. end;
  74.  
  75. { QstoreToScr - restores screen display                    ver 2.1, 12-09-86 }
  76. procedure QstoreToScr (Row, Col, Rows, Cols: byte; VAR Source);
  77. begin
  78. Inline(                  {Assembly by Inline 08/17/87 17:53}
  79.   $8B/$5E/<ROWS/         {       mov   bx,[bp+<Rows]    ;Move number of rows}
  80.   $8B/$4E/<COLS/         {       mov   cx,[bp+<Cols]    ;Move number of cols}
  81.                          {                              ;}
  82.   $85/$DB/               {       test  bx,bx            ;If Rows<=0 ...}
  83.   $7E/$68/               {       jle   Exit             ;   nothing to do}
  84.   $85/$C9/               {       test  cx,cx            ;If Cols<=0 ...}
  85.   $7E/$64/               {       jle   Exit             ;   nothing to do}
  86.                          {                              ;}
  87.   $31/$D2/               {       xor   dx,dx            ;Set DX=0}
  88.   $8E/$C2/               {       mov   es,dx            ;Set ES=0}
  89.   $26/                   {       es:                    ;Segment override}
  90.   $8A/$16/$4A/$04/       {       mov   dl,[$044A]       ;Get CRT columns}
  91.   $8B/$46/<ROW/          {       mov   ax,[bp+<Row]     ;Move row in AX}
  92.   $48/                   {       dec   ax               ;Convert to 0-?? range}
  93.   $F6/$E2/               {       mul   dl               ;(CRT columns)*(Row-1)}
  94.   $89/$C7/               {       mov   di,ax            ;Partial offset in DI}
  95.   $03/$7E/<COL/          {       add   di,[bp+<Col]     ;Add Col}
  96.   $4F/                   {       dec   di               ;Convert to 0-?? range}
  97.   $D1/$E7/               {       shl   di,1             ;Source offset calc'd}
  98.   $29/$CA/               {       sub   dx,cx            ;DX=(CRT columns)-Cols}
  99.   $D1/$E2/               {       shl   dx,1             ;Mult by 2}
  100.   $52/                   {       push  dx               ;Save # to next row}
  101.   $51/                   {       push  cx               ;Save Cols}
  102.   $1E/                   {       push  ds               ;Save Turbo's DS}
  103.   $FC/                   {       cld                    ;Set DF to increment}
  104.   $3A/$2E/>QWAIT/        {       cmp   ch,[>Qwait]      ;Check need for wait}
  105.   $8E/$06/>QSEG/         {       mov   es,[>Qseg]       ;ES:DI screen pointer}
  106.   $C5/$76/<SOURCE/       {       lds   si,[bp+<Source]  ;DS:SI source pointer}
  107.   $75/$0C/               {       jne   Color            ;  use Color routine}
  108.                          {                              ;}
  109.                          {; -- Mono routine; Attr, Char and No Wait--}
  110.   $F2/$A5/               {Mono:  rep   movsw            ;To dest & inc DI 2}
  111.   $4B/                   {       dec   bx               ;Decrement rows left}
  112.   $74/$2E/               {       jz    Done             ;If Rows=0, done}
  113.   $8B/$4E/$FA/           {       mov   cx,[bp-$06]      ;Restore Cols}
  114.   $01/$D7/               {       add   di,dx            ;Dest for next row}
  115.   $EB/$F4/               {       jmp   SHORT Mono       ;Next row}
  116.                          {                              ;}
  117.                          {; -- Color routine; Attr, Char and Wait --}
  118.   $BA/$DA/$03/           {Color: mov   dx,$03DA         ;CGA port}
  119.   $AD/                   {Col1A: lodsw                  ;Load char & attr}
  120.   $88/$C7/               {       mov   bh,al            ;Save char in BH}
  121.   $FA/                   {       cli                    ;Disable interrupts}
  122.   $EC/                   {E4in:  in    al,dx            ;Check CGA status}
  123.   $A8/$08/               {       test  al,$08           ;If #3 bit set ...}
  124.   $75/$09/               {       jnz   ColrB            ;  skip wait}
  125.   $D0/$D8/               {       rcr   al,1             ;If #0 bit set ...}
  126.   $72/$F7/               {       jc    E4in             ;  try again for $E4}
  127.   $EC/                   {E5in:  in    al,dx            ;Check CGA status}
  128.   $D0/$D8/               {       rcr   al,1             ;If #0 bit clear ...}
  129.   $73/$FB/               {       jnc   E5in             ;  try again for $E5}
  130.   $88/$F8/               {ColrB: mov   al,bh            ;Move char back in AL}
  131.   $AB/                   {       stosw                  ;Put in dest & inc DI}
  132.   $FB/                   {       sti                    ;Enable interrupts}
  133.   $E2/$E8/               {       loop  Col1A            ;Loop till CX=0}
  134.   $FE/$CB/               {       dec   bl               ;Decrement rows left}
  135.   $74/$08/               {       jz    Done             ;If Rows=0, done}
  136.   $8B/$4E/$FA/           {       mov   cx,[bp-$06]      ;Restore Cols}
  137.   $03/$7E/$FC/           {       add   di,[bp-$04]      ;Dest for next row}
  138.   $EB/$DC/               {       jmp   SHORT Col1A      ;Next row}
  139.                          {                              ;}
  140.   $1F/                   {Done:  pop   ds               ;Restore Turbo's DS}
  141.   $81/$C4/$04/$00        {       add   sp,$0004         ;Restore stack ptr}
  142.  );                      {Exit:}
  143. end;
  144.